﻿using HungryCrowd.HelperFunctions;
using HungryCrowdLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HungryCrowd.user
{
    public partial class update : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var saltedPassword = Helpers.GenerateSaltedPassword(txtPassword.Text,null);
            var success = false;
            // create user.
            var user = new User() { EmailAddress = txtEmail.Text, Password = saltedPassword, Salt = Helpers.Salt, Username = txtUsername.Text };
            success = API.UserManager.SaveChanges(user);

            if (success)
            {
                Response.Write("User created successfully!");
                Response.Redirect("default.aspx");
            }
        } 
    }
}